home *** CD-ROM | disk | FTP | other *** search
- /*
- File: MoreToolbox.cp
-
- Contains:
-
- Written by: Pete Gontier
-
- Copyright: Copyright (c) 1998 Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
-
- <5> 2/9/99 PCG lose QDGlobals and ShowWatchCursor
- <4> 1/29/99 PCG new Carbon
- <3> 1/22/99 PCG TARGET_CARBON
- <2> 11/11/98 PCG fix header
- <1> 11/10/98 PCG first big re-org at behest of Quinn
-
- Old Change History (most recent first):
-
- <3> 10/23/98 PCG add HavePowerManager
- <2> 7/24/98 PCG eliminate dependency on 'qd'
- <1> 6/16/98 PCG initial checkin
- */
-
- #include "MoreToolbox.h"
- #include "MoreQuickDraw.h"
- #include "MoreAppearance.h"
-
- #include <MacMemory.h>
- #include <Fonts.h>
- #include <Dialogs.h>
- #include <Sound.h>
- #include <Gestalt.h>
- #include <Power.h>
-
- static long gSystemVersion;
- static Boolean gHavePowerManager;
-
- pascal long GetSystemVersion (void)
- {
- //
- // Simply returns our cached variable. See InitMac
- // for how this variable is initialized.
- //
-
- return gSystemVersion;
- }
-
- pascal Boolean HaveAppleEvents (void)
- {
- return 0x0700 <= GetSystemVersion ( ); // cheating
- }
-
- pascal OSStatus InitMac (void)
- {
- OSStatus err = noErr;
-
- if (!(err = Gestalt (gestaltSystemVersion, &gSystemVersion)))
- {
- long powerMgrResponse;
- err = Gestalt (gestaltPowerMgrAttr,&powerMgrResponse);
-
- if (err == gestaltUndefSelectorErr)
- err = noErr;
- else if (!err)
- {
- gHavePowerManager = (powerMgrResponse & (1L << gestaltPMgrExists)) ? true : false;
-
- #if !TARGET_CARBON
-
- MaxApplZone ( );
- (void) MoreAssert (MemError ( ) == noErr);
-
- InitGraf (&(qd.thePort));
- InitFonts ( );
- InitWindows ( );
- InitMenus ( );
- TEInit ( );
- InitDialogs (nil);
-
- #endif
-
- if (!(err = InitMoreQuickDraw ( )))
- {
- if (!(err = InitMoreAppearance ( )))
- {
- err = ShowWatchCursor ( );
- }
- }
- }
- }
-
- return err;
- }
-
- pascal void Beep (void)
- {
- SysBeep (10);
- }
-
- pascal Boolean HavePowerManager (void)
- {
- return gHavePowerManager;
- }
-